package com.chentf.life;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

/**
 * @author chentengfei
 * @desc ...
 * @date 2021-01-11 23:45:03
 */
public class Product implements InitializingBean, DisposableBean {

    private String name;

    public void setName(String name) {
        System.out.println("Product.setName");
        this.name = name;
    }

    public Product() {
        System.out.println("Product.Product");
    }

    //这个就是InitializingBean借口的初始化方法,做一些初始化操作,Spring会自动调用
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("Porduct.afterPropertiesSet");
    }

    //自定义初始化方法,方法名任意
    public void myInit() {
        System.out.println("Product.myInit");
    }

    //销毁方法：销毁操作（资源释放的操作 ）
    @Override
    public void destroy() throws Exception {
        System.out.println("Product.destroy");
    }

    public void myDestroy() throws Exception {
        System.out.println("Product.myDestroy");
    }
}
